home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / programming / amos / amoslist-1294.lzh / AMOSLIST / text0118.txt < prev    next >
Encoding:
Text File  |  1995-01-03  |  675 b   |  26 lines

  1. >Just a quick question here.
  2. >
  3. >I want to be able to use the RND() function to create random numbers, yet
  4. >have those "random" numbers the same under certain circumstances.  See, I
  5. >want the user to be able to specify a "seed" number, so that inputting the
  6. >same "seed" will provide the same results.  Should I use RANDOMIZE SEED??? 
  7.  
  8.   No - that won't work (although it's supposed to - bug #153).  You'll have
  9. to use this random number routine:
  10.  
  11. Procedure RAND[_MAX]
  12.    HI=SEED/127773
  13.    LO=SEED mod 127773
  14.    TEST=16807*LO-2836*HI
  15.    If TEST>=0
  16.       SEED=TEST
  17.    Else
  18.       SEED=TEST+2147483647
  19.    End If
  20.    R#=SEED/2147483647.0
  21.    R=R#*_MAX
  22. End Proc[R]
  23.  
  24.   --Andy Church
  25.  
  26.